function getStyle(obj,attr){
  var value;
  if(obj.currentStyle){
    value= obj.currentStyle[attr];
  }else{
    value= window.getComputedStyle(obj,null)[attr];
  }
  //返回一个不带单位的属性值
  if(attr=="opacity"){
    return Math.round(parseFloat(value)*100);
  }else{
    return parseInt(value);
  }
}

function move(obj,attr,target,num,fn){
        if(obj.timer){
	      clearInterval(obj.timer);
		}
		// console.log(attr);  //test
		
	    obj.timer= setInterval(function(){
		//获取属性值，不带单位
		var current= (getStyle(obj,attr));
        if(!num){
		   num = 10;
		}
		// console.log(attr + " "+ current); //test
		var speed = (target-current)/num;
		speed>0 ? speed= Math.ceil(speed): speed=Math.floor(speed);
		// var speed =1;
		//比较属性值	 
		// console.log(target+" "+ current +" "+ speed);
		if(current != target){
		    if(attr=="opacity"){
		      obj.style[attr] = (current+speed)/100;
			  
			}else{
			  obj.style[attr] = current+speed+"px";
			}
		}else{
			clearInterval(obj.timer);
			if(fn){
			  fn();
			}
			
		}
		},30);
}